dynActorArray = {}

function addObjects()
    world:setPressingAction(PICKING_BODIES);
    ------------------
    Ground_wall = luajava.new(Ground)
    Ground_wall:addVertex(2.0, 480.0)
    Ground_wall:addVertex(2.0, 3.0)
    Ground_wall:addVertex(794.0, 3.0)
    Ground_wall:addVertex(794.0, 442.99997)
    Ground_wall:addVertex(782.0, 440.0)
    Ground_wall:addVertex(783.99994, 9.999999)
    Ground_wall:addVertex(642.0, 9.999999)
    Ground_wall:addVertex(637.0, 316.99997)
    Ground_wall:addVertex(627.0, 316.99997)
    Ground_wall:addVertex(633.99994, 9.999999)
    Ground_wall:addVertex(7.0, 9.999999)
    Ground_wall:addVertex(9.0, 470.0)
    Ground_wall:addVertex(840.0, 470.0)
    Ground_wall:addVertex(840.0, 480.0)
    Ground_wall:addVertex(9.0, 480.0)
    Ground_wall:setPosition(0.0, 0.0)
    Ground_wall:setRotation(0.0)
    Ground_wall:setName('Ground_wall')
    Ground_wall:setVisible(true)
    world:add(Ground_wall)

    ------------------
    Ground_w = luajava.new(Ground)
    Ground_w:addVertex(200.0, 417.0)
    Ground_w:addVertex(232.0, 333.0)
    Ground_w:addVertex(266.99997, 347.0)
    Ground_w:addVertex(257.0, 380.0)
    Ground_w:addVertex(282.0, 357.0)
    Ground_w:addVertex(316.99997, 365.0)
    Ground_w:addVertex(280.0, 442.0)
    Ground_w:addVertex(257.0, 433.0)
    Ground_w:addVertex(282.0, 378.0)
    Ground_w:addVertex(247.0, 400.0)
    Ground_w:addVertex(247.0, 358.0)
    Ground_w:addVertex(219.0, 419.99997)
    Ground_w:setPosition(-26.999998, 9.0)
    Ground_w:setRotation(0.0)
    Ground_w:setName('Ground_w')
    Ground_w:setVisible(true)
    Ground_w:setBodyType(DYNAMIC_BODY)
    world:add(Ground_w)

    ------------------
    Ground_a = luajava.new(Ground)
    Ground_a:addVertex(343.99997, 288.0)
    Ground_a:addVertex(362.0, 277.0)
    Ground_a:addVertex(397.0, 316.99997)
    Ground_a:addVertex(414.0, 308.0)
    Ground_a:addVertex(407.00003, 295.0)
    Ground_a:addVertex(389.0, 300.0)
    Ground_a:addVertex(380.0, 288.0)
    Ground_a:addVertex(402.0, 278.0)
    Ground_a:addVertex(393.99997, 260.0)
    Ground_a:addVertex(412.0, 253.0)
    Ground_a:addVertex(431.99997, 315.0)
    Ground_a:addVertex(391.99997, 335.0)
    Ground_a:setPosition(-26.999998, 37.0)
    Ground_a:setRotation(0.0)
    Ground_a:setName('Ground_a')
    Ground_a:setVisible(true)
    Ground_a:setBodyType(DYNAMIC_BODY)
    world:add(Ground_a)

    ------------------
    Ground_t = luajava.new(Ground)
    Ground_t:addVertex(232.0, 255.0)
    Ground_t:addVertex(240.00002, 236.99998)
    Ground_t:addVertex(274.0, 249.99995)
    Ground_t:addVertex(297.0, 208.0)
    Ground_t:addVertex(314.0, 214.99998)
    Ground_t:addVertex(291.99997, 257.0)
    Ground_t:addVertex(324.0, 270.0)
    Ground_t:addVertex(307.0, 290.0)
    Ground_t:setPosition(0.0, 0.0)
    Ground_t:setRotation(0.0)
    Ground_t:setName('Ground_t')
    Ground_t:setVisible(true)
    Ground_t:setBodyType(DYNAMIC_BODY)
    world:add(Ground_t)

    ------------------
    Ground_e = luajava.new(Ground)
    Ground_e:addVertex(380.0, 202.0)
    Ground_e:addVertex(437.0, 168.0)
    Ground_e:addVertex(452.0, 187.0)
    Ground_e:addVertex(414.0, 209.99998)
    Ground_e:addVertex(431.99997, 228.0)
    Ground_e:addVertex(454.0, 209.99998)
    Ground_e:addVertex(467.0, 228.0)
    Ground_e:addVertex(446.99997, 247.0)
    Ground_e:addVertex(462.0, 265.0)
    Ground_e:addVertex(492.0, 239.99998)
    Ground_e:addVertex(508.99997, 260.0)
    Ground_e:addVertex(456.99997, 290.0)
    Ground_e:setPosition(-72.99999, -133.0)
    Ground_e:setRotation(0.0)
    Ground_e:setName('Ground_e')
    Ground_e:setVisible(true)
    Ground_e:setBodyType(DYNAMIC_BODY)
    world:add(Ground_e)

    ------------------
    Ground_r = luajava.new(Ground)
    Ground_r:addVertex(57.0, 234.99998)
    Ground_r:addVertex(98.99999, 150.0)
    Ground_r:addVertex(119.99999, 163.0)
    Ground_r:addVertex(102.0, 192.0)
    Ground_r:addVertex(122.0, 200.0)
    Ground_r:addVertex(149.0, 173.0)
    Ground_r:addVertex(179.0, 187.0)
    Ground_r:addVertex(132.00003, 214.99998)
    Ground_r:addVertex(146.99998, 232.0)
    Ground_r:addVertex(132.00003, 260.0)
    Ground_r:addVertex(97.0, 262.0)
    Ground_r:addVertex(74.0, 245.0)
    Ground_r:addVertex(79.99999, 232.0)
    Ground_r:addVertex(98.99999, 245.0)
    Ground_r:addVertex(116.99999, 247.0)
    Ground_r:addVertex(127.0, 237.99998)
    Ground_r:addVertex(95.0, 203.0)
    Ground_r:addVertex(72.0, 241.99998)
    Ground_r:setPosition(62.0, 26.999998)
    Ground_r:setRotation(0.0)
    Ground_r:setName('Ground_r')
    Ground_r:setVisible(true)
    Ground_r:setBodyType(DYNAMIC_BODY)
    world:add(Ground_r)

    ------------------
    Ground_b = luajava.new(Ground)
    Ground_b:addVertex(102.0, 397.0)
    Ground_b:addVertex(114.0, 305.0)
    Ground_b:addVertex(174.0, 307.0)
    Ground_b:addVertex(186.99997, 340.0)
    Ground_b:addVertex(167.0, 352.0)
    Ground_b:addVertex(142.0, 353.0)
    Ground_b:addVertex(130.0, 350.0)
    Ground_b:addVertex(130.0, 335.0)
    Ground_b:addVertex(146.99998, 340.0)
    Ground_b:addVertex(170.0, 333.0)
    Ground_b:addVertex(155.0, 315.0)
    Ground_b:addVertex(130.0, 319.99997)
    Ground_b:addVertex(122.0, 363.0)
    Ground_b:addVertex(129.0, 355.0)
    Ground_b:addVertex(149.0, 362.0)
    Ground_b:addVertex(171.99998, 375.0)
    Ground_b:addVertex(174.0, 394.99997)
    Ground_b:addVertex(159.99998, 410.0)
    Ground_b:addVertex(127.0, 404.99997)
    Ground_b:addVertex(116.99999, 400.0)
    Ground_b:addVertex(119.99999, 390.0)
    Ground_b:addVertex(146.99998, 397.0)
    Ground_b:addVertex(159.00002, 390.0)
    Ground_b:addVertex(146.99998, 373.0)
    Ground_b:addVertex(122.0, 369.99997)
    Ground_b:addVertex(115.0, 400.0)
    Ground_b:setPosition(-42.0, 6.0)
    Ground_b:setRotation(0.0)
    Ground_b:setName('Ground_b')
    Ground_b:setVisible(true)
    Ground_b:setBodyType(DYNAMIC_BODY)
    world:add(Ground_b)

    ------------------
    Ground_l = luajava.new(Ground)
    Ground_l:addVertex(209.99998, 196.99998)
    Ground_l:addVertex(216.99998, 104.99999)
    Ground_l:addVertex(309.0, 112.999985)
    Ground_l:addVertex(297.0, 142.0)
    Ground_l:addVertex(236.99998, 133.0)
    Ground_l:addVertex(233.99998, 200.0)
    Ground_l:setPosition(-104.99999, -69.0)
    Ground_l:setRotation(0.0)
    Ground_l:setName('Ground_l')
    Ground_l:setVisible(true)
    Ground_l:setBodyType(DYNAMIC_BODY)
    world:add(Ground_l)

    ------------------
    Ground_k = luajava.new(Ground)
    Ground_k:addVertex(677.0, 358.0)
    Ground_k:addVertex(619.0, 266.99997)
    Ground_k:addVertex(633.99994, 255.0)
    Ground_k:addVertex(657.0, 290.0)
    Ground_k:addVertex(657.0, 245.0)
    Ground_k:addVertex(674.0, 234.99998)
    Ground_k:addVertex(670.0, 305.0)
    Ground_k:addVertex(737.0, 310.0)
    Ground_k:addVertex(710.0, 330.0)
    Ground_k:addVertex(675.0, 317.99997)
    Ground_k:addVertex(694.0, 347.0)
    Ground_k:setPosition(-252.0, 143.0)
    Ground_k:setRotation(0.0)
    Ground_k:setName('Ground_k')
    Ground_k:setVisible(true)
    Ground_k:setBodyType(DYNAMIC_BODY)
    world:add(Ground_k)

    ------------------
    Ground_o = luajava.new(Ground)
    Ground_o:addVertex(530.0, 397.0)
    Ground_o:addVertex(494.99997, 380.0)
    Ground_o:addVertex(492.0, 338.0)
    Ground_o:addVertex(502.0, 298.0)
    Ground_o:addVertex(539.0, 278.0)
    Ground_o:addVertex(577.0, 291.99997)
    Ground_o:addVertex(602.0, 332.0)
    Ground_o:addVertex(600.0, 372.0)
    Ground_o:addVertex(554.0, 400.0)
    Ground_o:addVertex(549.0, 385.0)
    Ground_o:addVertex(587.0, 363.0)
    Ground_o:addVertex(570.0, 315.0)
    Ground_o:addVertex(537.0, 300.0)
    Ground_o:addVertex(510.0, 322.0)
    Ground_o:addVertex(510.0, 362.0)
    Ground_o:addVertex(547.0, 385.0)
    Ground_o:addVertex(550.0, 400.0)
    Ground_o:setPosition(-104.99999, -112.0)
    Ground_o:setRotation(0.0)
    Ground_o:setName('Ground_o')
    Ground_o:setVisible(true)
    Ground_o:setBodyType(DYNAMIC_BODY)
    world:add(Ground_o)

    ------------------
    Ground_z = luajava.new(Ground)
    Ground_z:addVertex(471.99997, 195.0)
    Ground_z:addVertex(479.0, 175.0)
    Ground_z:addVertex(533.99994, 183.0)
    Ground_z:addVertex(487.0, 123.0)
    Ground_z:addVertex(487.0, 103.0)
    Ground_z:addVertex(572.0, 119.99999)
    Ground_z:addVertex(565.0, 142.0)
    Ground_z:addVertex(512.0, 128.0)
    Ground_z:addVertex(567.0, 202.0)
    Ground_z:setPosition(-260.0, -31.0)
    Ground_z:setRotation(0.0)
    Ground_z:setName('Ground_z')
    Ground_z:setVisible(true)
    Ground_z:setBodyType(DYNAMIC_BODY)
    world:add(Ground_z)

    world:addInteractType(GROUND)

    table.insert(dynActorArray, Ground_w)
    table.insert(dynActorArray, Ground_a)
    table.insert(dynActorArray, Ground_t)
    table.insert(dynActorArray, Ground_e)
    table.insert(dynActorArray, Ground_r)
end
function onCreate()
    addObjects()
end

won = false
function onCheck()
    for i = 1, #dynActorArray do
        local pos = dynActorArray[i]:getPosition()
        if pos.x < 600 then
            return false
        end
    end

    if won == false then
        for i = 0, 8 do
            for j = 0, 35 do
                local drop = luajava.new(Drop)
                drop:setPosition(luajava.new(Vector2, i * 9 + 670, j * 9 + 20))
                world:addDropToCreate(drop)
            end
        end

        for i = 1, #dynActorArray do
            dynActorArray[i]:setPosition(-1000, -1000)
        end

        won = true
    end

    return true
end